/*
package com.bupt.secret.controller;


import com.bupt.secret.dto.RSArefPublicKey;
import com.bupt.secret.query.*;
import com.bupt.secret.utils.BuptClientUtil;
import com.bupt.secret.utils.BuptResultDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.swing.*;
import java.nio.charset.StandardCharsets;


*/
/**
 * @author shishumin
 * @title DeviceUserController
 * @date 2024/09/07 11:52
 * @description TODO
 *//*

@Slf4j
@RestController
@RequestMapping("/api/secret")
public class SecretApiController {

    */
/**
     * @desc 打开会话
     * @author shishumin
     * @date 2024/9/7 11:02
     *//*

    @GetMapping("/openDevice")
    public BuptResultDto openDevice(){
        return BuptClientUtil.openDevice();
    }

    */
/**
     * @desc 打开会话
     * @author shishumin
     * @date 2024/9/7 11:02
     *//*

    @GetMapping("/openSession")
    public BuptResultDto openSession(){
        return BuptClientUtil.openSession();
    }

    */
/**
     * @desc 关闭会话
     * @author shishumin
     * @date 2024/9/7 11:02
     *//*

    @GetMapping("/closeSession")
    public BuptResultDto closeSession(@RequestParam Long sessionHandle){
        return BuptClientUtil.closeSession(sessionHandle);
    }

    */
/**
     * @desc 获取RSA加密公钥
     * @author shishumin
     * @date 2024/9/7 11:18
     *//*

    @GetMapping("/getEncPublicKeyRSA")
    public BuptResultDto<RSArefPublicKey> getEncPublicKeyRSA(@RequestParam Long sessionHandle, @RequestParam Integer uiKeyIndex){
        return BuptClientUtil.exportEncPublicKeyRSA(sessionHandle, uiKeyIndex);
    }

    */
/**
     * @desc 获取RSA签名公钥
     * @author shishumin
     * @date 2024/9/7 11:18
     *//*

    @GetMapping("/getSignPublicKeyRSA")
    public BuptResultDto getSignPublicKeyRSA(@RequestParam Long sessionHandle, @RequestParam Integer uiKeyIndex){
        return BuptClientUtil.exportSignPublicKeyRSA(sessionHandle, uiKeyIndex);
    }

    */
/**
     * @desc 生成指定模长的RSA密钥对
     * @author shishumin
     * @date 2024/9/7 11:22
     *//*

    @GetMapping("/generatePinKeyPairRSA")
    public BuptResultDto generateKeyPairRSAV2(@RequestParam Long sessionHandle,
                                              @RequestParam Integer uiKeyIndex,
                                              @RequestParam String pin,
                                              @RequestParam Integer secertKeyAlgID){
        return BuptClientUtil.generateKeyPairRSAV2(sessionHandle, uiKeyIndex, pin, secertKeyAlgID);
    }

    */
/**
     * @desc 生成会话密钥并用RSA公钥加密
     * @author shishumin
     * @date 2024/9/7 11:34
     *//*

    @PostMapping("/generateKeyWithEPKRSA")
    public BuptResultDto generateKeyWithEPKRSA(@RequestBody SessionKeyPublicRSAParam keyPublicRSAParam){
        RSArefPublicKey pucPublicKey = keyPublicRSAParam.getPucPublicKey();
        if (pucPublicKey == null) {
            BuptResultDto<RSArefPublicKey> encPublicKeyRSA = this.getEncPublicKeyRSA(keyPublicRSAParam.getSessionHandle(), keyPublicRSAParam.getUiKeyBits());
            pucPublicKey = encPublicKeyRSA.getData();
        }
        return BuptClientUtil.generateKeyWithEPKRSA(keyPublicRSAParam.getSessionHandle(),
                keyPublicRSAParam.getUiKeyBits(), pucPublicKey);
    }

    */
/**
     * @desc 导入会话密钥并用RSA私钥解密
     * @author shishumin
     * @date 2024/9/7 11:43
     *//*

    @PostMapping("/importKeyWithISKRSA")
    public BuptResultDto importKeyWithISKRSA(@RequestBody SessionSecretPucKeyParam pucKeyParam){
        byte[] pucKeyDate = pucKeyParam.getPucKey().getBytes(StandardCharsets.UTF_8);
        return BuptClientUtil.importKeyWithISKRSA(pucKeyParam.getSessionHandle(),
                pucKeyParam.getUiISKIndex(), pucKeyDate, pucKeyDate.length);
    }

    */
/**
     * @desc 指定使用外部公钥RSA对数据进行运算
     * @author shishumin
     * @date 2024/9/7 11:43
     *//*

    @PostMapping("/externalPublicKeyOperationRSA")
    public BuptResultDto externalPublicKeyOperationRSA(@RequestBody SessionPublicKeyDataParam pucKeyParam){
        byte[] pucKeyDate = pucKeyParam.getPucDataInput().getBytes(StandardCharsets.UTF_8);
        return BuptClientUtil.externalPublicKeyOperationRSA(pucKeyParam.getSessionHandle(),
                pucKeyParam.getPucPublicKey(), pucKeyDate, pucKeyDate.length);
    }

    */
/**
     * @desc 指定使用内部指定RSA私钥对数据进行运算
     * @author shishumin
     * @date 2024/9/7 11:47
     *//*

    @PostMapping("/internalPublicKeyOperationRSA")
    public BuptResultDto internalPublicKeyOperationRSA(@RequestBody SessionPublicKeyDataParam pucKeyParam){
        byte[] pucKeyDate = pucKeyParam.getPucDataInput().getBytes(StandardCharsets.UTF_8);
        return BuptClientUtil.internalPublicKeyOperationRSA(pucKeyParam.getSessionHandle(),
                pucKeyParam.getUiKeyIndex(), pucKeyDate, pucKeyDate.length);
    }

    */
/**
     * @desc 数据加密
     * @author shishumin
     * @date 2024/9/7 11:59
     *//*

    @PostMapping("/encrypt")
    public BuptResultDto encrypt(@RequestBody SessionPublicDataEncryptParam pucKeyParam){
        byte[] pucKeyData = pucKeyParam.getPucData().getBytes(StandardCharsets.UTF_8);
        byte[] pucIV = pucKeyParam.getPucIV().getBytes(StandardCharsets.UTF_8);
        return BuptClientUtil.encrypt(pucKeyParam.getSessionHandle(), pucKeyParam.getHKeyHandle(), pucKeyParam.getUiAlgID(),
                pucIV, pucKeyData, pucKeyData.length);
    }

    */
/**
     * @desc 数据解密
     * @author shishumin
     * @date 2024/9/7 11:59
     *//*

    @PostMapping("/decrypt")
    public BuptResultDto decrypt(@RequestBody SessionPublicDataDecryptParam pucKeyParam){
        byte[] pucKeyData = pucKeyParam.getPucEncData().getBytes(StandardCharsets.UTF_8);
        byte[] pucIV = pucKeyParam.getPucIV().getBytes(StandardCharsets.UTF_8);
        return BuptClientUtil.decrypt(pucKeyParam.getSessionHandle(), pucKeyParam.getHKeyHandle(), pucKeyParam.getUiAlgID(),
                pucIV, pucKeyData, pucKeyData.length);
    }

}
*/
